/*****************************************************************************
 * Copyright (c) 2019, Nations Technologies Inc.
 *
 * All rights reserved.
 * ****************************************************************************
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the disclaimer below.
 *
 * Nations' name may not be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ****************************************************************************/

/**
 * @file main.h
 * @author Nations 
 * @version v1.0.0
 *
 * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
 */
#ifndef __MAIN_H__
#define __MAIN_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "n32g030.h"
#include "def_var.h"
//#include "motor.h"

/*Led1-PB1,Led2-PB6,Led3-PB7*/


#define	ChuChouPowerOn	GPIO_SetBits(CHUCHOU_PORT, CHUCHOU_PIN)
#define	ChuChouPowerOff	GPIO_ResetBits(CHUCHOU_PORT, CHUCHOU_PIN)
#define	QiBangPowerOn	GPIO_SetBits(QIBANG_PORT,	QIBANG_PIN)
#define	QiBangPowerOff	GPIO_ResetBits(QIBANG_PORT,	QIBANG_PIN)

#define	ZQHEATPowerOn		GPIO_ResetBits(ZQ_HEAT_PORT, ZQ_HEAT_PIN)
#define	ZQHEATPowerOff		GPIO_SetBits(ZQ_HEAT_PORT, ZQ_HEAT_PIN)
#define	HGPowerOn		GPIO_ResetBits(HG_ON_PORT, HG_ON_PIN)
#define	HGPowerOff		GPIO_SetBits(HG_ON_PORT, HG_ON_PIN)
#define	ShuiHotPowerOn	GPIO_SetBits(HOT_ON_PORT,	HOT_ON_PIN)
#define	ShuiHotPowerOff	GPIO_ResetBits(HOT_ON_PORT,	HOT_ON_PIN)

	


#define	ZQ_HEAT_PORT	GPIOF
#define	ZQ_HEAT_PIN	GPIO_PIN_1
#define	HOT_ON_PORT	GPIOF
#define	HOT_ON_PIN	GPIO_PIN_0
#define	HG_ON_PORT	GPIOC
#define	HG_ON_PIN	GPIO_PIN_15
#define	QIBANG_PORT	GPIOA
#define	QIBANG_PIN	GPIO_PIN_10
#define	CHUCHOU_PORT	GPIOA
#define	CHUCHOU_PIN	GPIO_PIN_11

#define	BUZZER_BASE_CLOCK	12000000
#define	SPK_PORT	GPIOA
#define	SPK_PIN		GPIO_PIN_15
#define	SPK_PowerOn	GPIO_SetBits(SPK_PORT,SPK_PIN)
#define	SPK_PowerOff	GPIO_ResetBits(SPK_PORT,SPK_PIN)
#define	UPS_PORT	GPIOC
#define	UPS_PIN		GPIO_PIN_13
#define	UPS_PowerOn	GPIO_SetBits(UPS_PORT,UPS_PIN)
#define	UPS_PowerOff	GPIO_ResetBits(UPS_PORT,UPS_PIN)

const SETTING_ITEM setting_item[Setting_Len] = 
{	{1,100,1},
	{0,23,1},
	{0,23,1},
	{0,120,30},
	{30,900,30},
	{0,120,30},
	{30,900,30},
	{0,23,1},
	{0,59,1},
};

void Delay(uint32_t count);
void	BuzzerInit(void);

void		Display_LED(void);
void	InitialMonitor(void);
extern	void	LED_PowerOn(U8 leds);
extern	void		LED_PowerOff(U8 leds);	

extern	void	InitStepMotorTimer(void);
extern	void	InitialADC(void);
//extern	bool	Check_Input_DC(void);
extern	void	InitialSensor(void);
extern	bool	Check_AC_Input(void);
extern	U8	ReadKey(void);
extern	void	DisplayStatus(bool initial,bool LEDPowerOn,U8 * LedSts);
extern	void	UpdateLEDStatus(void);
extern	void	WaitReleaseKey(void);
extern	void	Init_UP_DOWN_DCMotor(void);
extern	void	Init_StepMotor(void);
extern	void delay_ms(u16 ms);
extern	void	Board_Initial(void);
extern	void KeyInputExtiInit(GPIO_Module* GPIOx, uint16_t Pin);
//extern	void	WuHuaWorking(void);
extern	void	ChouYePowerOn(void);
extern	void	Buzzer(u8 count);
extern	u32	HX711_Read(void);
extern void Calibrate(int32_t * pHXOffset,float * pHXAdjust);

extern	float Get_Weight(void);
extern	void InitialSetting(void);
extern	void	SaveSetting(U8 * pbAddr,U8 len);
extern	void		ProcessMachineStatus(void);
extern	void	StartDevice(void);	
extern	void RTC_Config(void);
extern	ErrorStatus RTC_DateRegulate(void);
extern	ErrorStatus RTC_TimeRegulate(void);
extern	ErrorStatus RTC_ConfigTime(uint32_t RTC_Format, RTC_TimeType* RTC_TimeStruct);
extern	void	TZ_Sensor_PowerOn(bool);

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H__ */
/**
 * @}
 */

/**
 * @}
 */

/**
 * @}
 */
